#encoding:utf8 
import urllib, urllib2
from urllib import unquote, quote_plus

from urllib2 import urlopen




#SR搜索器
class BaseSrer:
    #豆瓣的图书搜索
    _sweb = ""
    _url = ""

    timeout_sec = 5
    retry_times = 3

    def __init__(self, baseurl):
        self._sweb = baseurl

    def get_srurl(self, svalue):
        self._url = self._sweb%(str(svalue))
    	# self._url = self._sweb%(str(quote_plus(svalue)))
        return self._url

    def start_sr(self, callback):

        #todo retry_times
    	req = urllib2.urlopen(self._url, timeout = self.timeout_sec)
        ret = req.read()

        #tchk ret 
        return ret